package org.linlinjava.litemall.db.service;

import java.time.LocalDateTime;

import javax.annotation.Resource;

import com.github.yulichang.base.MPJBaseServiceImpl;
import org.linlinjava.litemall.db.dao.LitemallAccountBookMapper;
import org.linlinjava.litemall.db.domain.LitemallAccountBook;
import org.linlinjava.litemall.db.dto.LitemallAccountBookFormDto;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
public class LitemallAccountBookService extends MPJBaseServiceImpl<LitemallAccountBookMapper,LitemallAccountBook> {
	
	@Resource
    private LitemallAccountBookMapper litemallAccountBookMapper;
	
	public void create(Integer shopId, LitemallAccountBookFormDto form) {
		LitemallAccountBook litemallAccountBook = new LitemallAccountBook();
		BeanUtils.copyProperties(form, litemallAccountBook);
		//litemallAccountBook.setShopId(shopId);
		LocalDateTime recordDate = form.getRecordDate();
		int year = recordDate.getYear();
		int month = recordDate.getMonth().getValue();
		litemallAccountBook.setYear(year);
		litemallAccountBook.setMonth(month);
		litemallAccountBook.setAddTime(LocalDateTime.now());
		litemallAccountBook.setUpdateTime(LocalDateTime.now());
		litemallAccountBookMapper.insert(litemallAccountBook);
	}

}
